from pyecharts.charts import Bar
from pyecharts import options as opts

bar = (
    Bar()
    .add_xaxis(["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"])
    .add_yaxis("商家A", [5, 20, 36, 10, 75, 90], stack="test")  # stack叠加
    .add_yaxis("商家B", [5, 3, 6, 10, 75, 9], stack="test2")
    # 全局配置项目
    .set_global_opts(
        title_opts=opts.TitleOpts(title="21软工三班陈志雄", subtitle="小黑子"),
        legend_opts=opts.LegendOpts(
            type_='scroll', selected_mode="multiple", pos_right="50%", legend_icon='circle'),
        # 提示框
        tooltip_opts=opts.TooltipOpts(
            trigger="item",  # 触发类型,'axis': 坐标轴触发，主要在柱状图，折线图等会使用类目轴的图表中使用。
            trigger_on='mousemove',  # 触发条件click,mousemove
            formatter='{a}[ {b} ] = {c}元'
        ),
        # 区域缩放
        datazoom_opts=opts.DataZoomOpts(
            is_show=True,
            type_="slider",  # 组件类型：inside在图表中缩放
            is_realtime=True,
            range_start=0,
            range_end=80,
            orient='horizontal',
            is_zoom_lock=False,
        ),
        # 坐标轴配置项
        xaxis_opts=opts.AxisOpts(
            # 轴线
            axisline_opts=opts.AxisLineOpts(
                is_show=True,
                symbol=['none', 'arrow']
            ),
            # 刻度
            axistick_opts=opts.AxisTickOpts(
                is_show=False,
            )
        ),
        yaxis_opts=opts.AxisOpts(
            # 轴线
            axisline_opts=opts.AxisLineOpts(
                is_show=True,
                symbol=['none', 'arrow']
            ),
            # 刻度
            axistick_opts=opts.AxisTickOpts(
                is_show=True,
            )
        )
    )
    # 系列配置项
    # .set_series_opts(opts.)
)
bar.render("bar1.html")
